package com.frinder.base.server;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.group.ChannelGroup;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName ServerInitializer
 * @Author frinder
 * @Description 服务端消息处理链
 * @Date 2018/11/28 19:36
 * @Version 1.0
 */
@Slf4j
public class ServerInitializer extends ChannelInitializer<Channel> {

    private final ChannelGroup channels;

    public ServerInitializer(ChannelGroup channels) {
        this.channels = channels;
    }

    @Override
    protected void initChannel(Channel channel) {
        log.debug("*** 初始化渠道链！");
//        ChannelPipeline pipeline = channel.pipeline();
//        // 日志处理器
//        pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));
//
//        // 解码&编码 机制，需要放在最前面，后面所有过滤器都需要先进行 编码&解码
//        pipeline.addLast(MarshallingCodeCFactory.decoder());
//        pipeline.addLast(MarshallingCodeCFactory.encoder());
//
//        // 心跳检测机制
//        pipeline.addLast(new IdleStateHandler(READ_IDL_TIME_OUT, WRITE_IDL_TIME_OUT, ALL_IDL_TIME_OUT, TimeUnit.SECONDS));
//        pipeline.addLast(new HeartbeatHandler());
//
//        // 客户端监听机制
//        pipeline.addLast(new ClientManagerHandler(channels));
//
//        // 服务端消息处理机制，必须放置在处理链最后
    }

}
